home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: What does the -O option do???!!!
- Date: Fri, 09 Feb 96 00:50:08 GMT
- Organization: none
- Message-ID: <823827008snz@genesis.demon.co.uk>
- References: <4ehger$cj9@mark.ucdavis.edu> <4emlsq$odt@airdmhor.gen.nz> <pronet01.34.003B9BB5@indirect.com>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <pronet01.34.003B9BB5@indirect.com>
- pronet01@indirect.com "Mark Miller" writes:
-
- >Hint: When you're done using a pointer (and it has not gone out of
- >scope), explicitly set it to NULL..
-
- Why? If you're done with a variable the value it contains is immaterial.
-
- > I have seen the optimized version
- >move addresses for a pointer variable that you have used "free" on..
-
- As far as the C language is concerned the value of a pointer is
- indeterminate if the object it pointed to has been freed. Therefore code
- that tries to use the value of a pointer after that has been passed to
- free is plain broken (except possibly, as has been argued on comp.stc.c,
- if that value is accessed as a char array). So if a compiler can generate
- more efficient code my making use of this then that is a good compiler and
- all correct programs will continue to work with it.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-